<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib prefix="sql" uri="http://java.sun.com/jsp/jstl/sql"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<ul id="nav">
    
    <sql:query var="queryPrincipal" dataSource="jdbc/dbo_MicrosoftSQLServer">
        select *
        from menus
            inner join acessos on menus.id_menu=acessos.id_menu
        where (id_menu_sup=0 or id_menu_sup is null)
            and acessos.id_perfil=?
        order by ordem_menu
            <sql:param value="${sessionScope.id_perfil}"/>
    </sql:query>
    <c:forEach var="rowP" items="${queryPrincipal.rows}">
        <li>            
            <a href="#"><b>${rowP.nome_menu}</b></a>
        <sql:query var="queryPrincipal" dataSource="jdbc/dbo_MicrosoftSQLServer">
            select *
            from menus
            inner join acessos on menus.id_menu=acessos.id_menu
            where (id_menu_sup=0 or id_menu_sup is null)
            and acessos.id_perfil=?
            order by ordem_menu
            <sql:param value="${sessionScope.id_perfil}"/>
        </sql:query>
        <sql:query var="queryF" dataSource="jdbc/dbo_MicrosoftSQLServer">
            select *
            from menus
            inner join acessos on menus.id_menu=acessos.id_menu
            where (id_menu_sup=?)
            and acessos.id_perfil=?
            order by ordem_menu
            <sql:param value="${rowP.id_menu}"/>
            <sql:param value="${sessionScope.id_perfil}"/>
        </sql:query>
            <ul>
                <c:forEach var="rowF" items="${queryF.rows}">
                    <li><a href="${rowF.caminho_menu}" target="principal">${rowF.nome_menu}</a></li>
                </c:forEach>
            </ul>
        </li>
   </c:forEach>   
    <li><a href="/sgd/sair.jsp"><b>Sair</b></a></li>
</ul>

